﻿using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IsreversI.GUI
{
    class NewGameDialog : Form
    {
        #region membervars
        private Label label1;
        private Label label2;
        private NumericUpDown xSpinBox;
        private NumericUpDown ySpinBox;
        private Label label3;
        private Button startButton;
        private Button cancelButton;

        private GameLogic.GameStateView stateView;
        #endregion

        #region constructors
        public NewGameDialog(GameLogic.GameStateView gameStateView)
        {
            this.InitializeComponent();
            this.stateView = gameStateView;
        }

        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.xSpinBox = new System.Windows.Forms.NumericUpDown();
            this.ySpinBox = new System.Windows.Forms.NumericUpDown();
            this.label3 = new System.Windows.Forms.Label();
            this.startButton = new System.Windows.Forms.Button();
            this.cancelButton = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.xSpinBox)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.ySpinBox)).BeginInit();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 22);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(141, 13);
            this.label1.TabIndex = 9;
            this.label1.Text = "Specify the size of the board";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(17, 62);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(50, 13);
            this.label2.TabIndex = 9;
            this.label2.Text = "Columns:";
            // 
            // xSpinBox
            // 
            this.xSpinBox.Location = new System.Drawing.Point(94, 60);
            this.xSpinBox.Maximum = new decimal(new int[] {
            20,
            0,
            0,
            0});
            this.xSpinBox.Minimum = new decimal(new int[] {
            3,
            0,
            0,
            0});
            this.xSpinBox.Name = "xSpinBox";
            this.xSpinBox.Size = new System.Drawing.Size(47, 20);
            this.xSpinBox.TabIndex = 1;
            this.xSpinBox.Value = new decimal(new int[] {
            6,
            0,
            0,
            0});
            // 
            // ySpinBox
            // 
            this.ySpinBox.Location = new System.Drawing.Point(94, 86);
            this.ySpinBox.Maximum = new decimal(new int[] {
            20,
            0,
            0,
            0});
            this.ySpinBox.Minimum = new decimal(new int[] {
            3,
            0,
            0,
            0});
            this.ySpinBox.Name = "ySpinBox";
            this.ySpinBox.Size = new System.Drawing.Size(47, 20);
            this.ySpinBox.TabIndex = 2;
            this.ySpinBox.Value = new decimal(new int[] {
            6,
            0,
            0,
            0});
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(17, 88);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(37, 13);
            this.label3.TabIndex = 9;
            this.label3.Text = "Rows:";
            // 
            // startButton
            // 
            this.startButton.Location = new System.Drawing.Point(12, 143);
            this.startButton.Name = "startButton";
            this.startButton.Size = new System.Drawing.Size(75, 23);
            this.startButton.TabIndex = 3;
            this.startButton.Text = "Start Game";
            this.startButton.UseVisualStyleBackColor = true;
            this.startButton.Click += new System.EventHandler(this.startNewGame);
            // 
            // cancelButton
            // 
            this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.cancelButton.Location = new System.Drawing.Point(94, 143);
            this.cancelButton.Name = "cancelButton";
            this.cancelButton.Size = new System.Drawing.Size(75, 23);
            this.cancelButton.TabIndex = 4;
            this.cancelButton.Text = "Cancel";
            this.cancelButton.UseVisualStyleBackColor = true;
            this.cancelButton.Click += new System.EventHandler(this.closeDialog);
            // 
            // NewGameDialog
            // 
            this.AcceptButton = this.startButton;
            this.CancelButton = this.cancelButton;
            this.ClientSize = new System.Drawing.Size(187, 178);
            this.Controls.Add(this.cancelButton);
            this.Controls.Add(this.startButton);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.ySpinBox);
            this.Controls.Add(this.xSpinBox);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            this.Name = "NewGameDialog";
            this.ShowInTaskbar = false;
            this.Text = "New Game";
            ((System.ComponentModel.ISupportInitialize)(this.xSpinBox)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.ySpinBox)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }
        #endregion

        #region event handlers
        private void startNewGame(object sender, EventArgs e)
        {
            this.stateView.BoardModel = new GameLogic.BoardModel(new Size((int)this.xSpinBox.Value, (int)this.ySpinBox.Value));
            this.Close();
        }

        private void closeDialog(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion

    }
}
